<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <test ref="t"></test>
        <button @click="handleClick">获取test 组件上的信息，通过 ref</button>
    </div>
    <script src="./vue.js"></script>
    <script>
        // 方便实现总线模式的
        Vue.component("test",{
            mounted() {
                console.log(location.href);// 获取组件之间传递的参数
                console.log(document.cookie);// cookie
                console.log(localStorage.getItem("log"))
            },
            template:`
                <div><h1>Test 组件</h1> <demo></demo></div>
            `
        })
        Vue.component("demo",{
            inject:["name"],
            template:`
                <div><h1>Demo组件{{name}}</h1></div>
            `
        })
        let vm = new Vue({
            provide:{
                name:"Vue"
            },
            el:"#app",
            data:{
                num:100
            },
            methods: {
                handleClick:function(){
                    console.log(this.$refs.t);// 获取组件中相关信息了
                }
            },
        })
    </script>
</body>
</html>